Object.defineProperty(exports, "__esModule", {
  value: true
});
var $2ConstValue = require("ConstValue");
var $2AudioManager = require("AudioManager");
var def_KS_VideoMgr = /* */function () {
  function _ctor() {
    babel_classCallCheck(this, _ctor);
    this._rewardVideoAd = new Map();
    this._rewardcomplat = new Map();
    this.currentgame = window.kwaigame;
  }
  return babel_createClass(_ctor, [{
    key: "Create",
    value: function Create(e, t) {
      this._rewardcomplat.set(e, t);
      var n = this;
      if (0 == this._rewardVideoAd.has(e)) {
        var _t24 = {};
        _t24.adUnitId = e;
        var _s5 = this.currentgame.createRewardedVideoAd(_t24);
        if (_s5) {
          console.log("激励广告组件获取成功");
          _s5.onClose(function (t) {
            if (t && t.isEnded) {
              console.log("激励视频关闭回调: " + JSON.stringify(t));
              cc.game.resume();
              $2AudioManager.AudioManager.getInstance().resumeAll();
              var _s6 = n._rewardcomplat.get(e);
              if (null != _s6) {
                _s6(false);
                cc.director.emit("MYSELF_TOUCH_END", "playfail");
              }
              $2ConstValue.ConstValue.InterAdIntervalTime += $2ConstValue.ConstValue.INCENTIVE_VIDEO_INTERVAL_KS;
            } else {
              console.log("中途退出");
            }
          });
          _s5.onReward(function (t) {
            cc.game.resume();
            $2AudioManager.AudioManager.getInstance().resumeAll();
            var o = n._rewardcomplat.get(e);
            if (null != o) {
              o(true);
              n._rewardcomplat.set(e, null);
              cc.director.emit("MYSELF_TOUCH_END", "playok");
            }
            console.log("激励视频奖励回调: " + JSON.stringify(t));
          });
        } else {
          console.log("激励广告组件获取失败");
          cc.game.resume();
          $2AudioManager.AudioManager.getInstance().resumeAll();
        }
        this._rewardVideoAd.set(e, _s5);
      }
    }
  }, {
    key: "destroy",
    value: function destroy(e) {
      if (this._rewardVideoAd.has(e)) {
        this._rewardVideoAd.get(e).destroy();
        this._rewardVideoAd.delete(e);
        this._rewardcomplat.delete(e);
      }
    }
  }, {
    key: "playvideo",
    value: function playvideo(e, t) {
      this.Create(e, t);
      var n = this._rewardVideoAd.get(e);
      if (n) {
        n.show({
          success() {
            console.log("激励视频播放成功");
            cc.game.pause();
            $2AudioManager.AudioManager.getInstance().pauseAll();
          },
          fail(e) {
            console.log("激励视频播放失败: " + JSON.stringify(e));
          }
        });
      } else {
        console.log("请先获取激励视频组件");
      }
    }
  }], [{
    key: "Instance",
    get() {
      _ctor._instance || (_ctor._instance = new _ctor());
      return _ctor._instance;
    }
  }]);
}();
exports.default = def_KS_VideoMgr;